<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2017/8/28
 * Time: 下午3:29
 */

namespace app\index\validate;

use think\Validate;
//自检报告
class Valid extends Validate
{
    protected $rule = [
    ];
    // 经销商名称不允许英文状态下输入单引号！
    protected function checkJxsmc($value,$rule,$data)
    {

        return false === strpos($value,"'") ? true : '名称不允许英文状态下输入单引号！';
    }
    // 验证手机号！
    protected function cgMobile($value,$rule,$data)
    {
        if(!preg_match("/^1[34578]\d{9}$/", $value)){
            return '请输入正确的手机号';
        }else{
            return true;
        }
    }
    // 验证电话号！
    protected function cgPhone($value,$rule,$data)
    {
        if(!preg_match(" /^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/", $value)){
            return false;
        }else{
            return true;
        }
    }

    protected function cgPhoneOrMobile($value,$rule,$data)
    {
        if(preg_match(" /^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/", $value) || preg_match(" /^1[34578]\d{9}$/", $value)){
            return true;
        }else{
            return false;
        }
    }
    //匹配金额是否正确
    protected function jine($value,$rule,$data)
    {
        if(preg_match(" /^[0-9]+(.[0-9]{1,2})?$/", $value)){
            return true;
        }else{
            return false;
        }
    }
}